<%-- 
    Document   : UserSave
    Created on : 10/10/2011, 04:49:35 PM
    Author     : Alumnos
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.sql.*" %>
<%@page import="Examen.lp1.Conexion" %>
<%
String go=request.getParameter("go");
if(go.equals("Create"))
        try {
            Conexion conn = new Conexion();
            //test
            String qry="insert into User(UserId,photo,Name, Email,celular,Login,Password,Privilege,ActiveAccount,ForcePasswordChange) values(?,?,?,?,?,?,?,?,?,?,?)";
            PreparedStatement ps=conn.getConnection().prepareStatement(qry);
            ps.setString(1, request.getParameter("`Name`") );
            ps.setInt(2, Integer.parseInt(request.getParameter("Password")));
            int r=ps.executeUpdate();
            out.println(r+" Create in User table<br>");
            conn.close();
        } catch (Exception e) {
            out.print("Error: " +e.getMessage());
        }
if(go.equals("Edit"))
        try {
            Conexion conn = new Conexion();
            //test
            String qry="update User set "+
                    "Photo=?,`Name`=?,Email=?,Celular=?,Login=? Password=?,Privilege=?,ActiveAccount=?,ForcePasswordChange=?"+
                    " where UserId=?";
            PreparedStatement ps=conn.getConnection().prepareStatement(qry);
            ps.setString(1, request.getParameter("`Name`") );
            ps.setInt(2, Integer.parseInt(request.getParameter("Password")));
            ps.setString(3, request.getParameter("UserId") );
            int r=ps.executeUpdate();
            out.println(r+" edit in User table<br>");
            conn.close();
        } catch (Exception e) {
            out.print("Error: " +e.getMessage());
        }    
if(go.equals("Delete"))
        try {
            Conexion conn = new Conexion();
            //test
            String qry="delete from User where UserId=?";
            PreparedStatement ps=conn.getConnection().prepareStatement(qry);
            ps.setString(1, request.getParameter("UserId") );
            int r=ps.executeUpdate();
            out.println(r+"delete of User table<br>");
            conn.close();
        } catch (Exception e) {
            out.print("Error: " +e.getMessage());
        }  
%>
Espere...
<meta http-equiv="refresh" content="1;URL=UserMain.jsp" >